#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 创建菜单栏
    QMenuBar* menuBar = new QMenuBar();
    this->setMenuBar(menuBar);

    // 创建父菜单与子菜单
    QMenu* parentMenu = new QMenu("父菜单");
    QMenu* childMenu = new QMenu("子菜单");
    menuBar->addMenu(parentMenu);
    parentMenu->addMenu(childMenu);

    // 创建子菜单的菜单项与子菜单的子菜单
    QAction* action1 = new QAction("菜单项1");
    QAction* action2 = new QAction("菜单项2");
    childMenu->addAction(action1);
    childMenu->addAction(action2);

    QMenu* childMenu2 = new QMenu("子菜单2");
    childMenu->addMenu(childMenu2);

}

MainWindow::~MainWindow()
{
    delete ui;
}

